import React, { createRef } from 'react';
class TestRef4 extends React.Component {

    input2 = createRef()

    getVal = () => {
        this.input2.current.value = this.input1.value
    }

    render() {
        return (<div>
            <input type="text" ref={(input) => { this.input1 = input }} />

            <button onClick={() => { this.getVal() }}>按钮</button>

            <input type="text" ref={this.input2} />
        </div>)
    }
}
export default TestRef4;